package com.akkainaction.helloactor.life.actor;

import akka.actor.UntypedActor;
import scala.Option;

public class UuidActor extends UntypedActor {

    @Override
    public void preStart() throws Exception {
        System.out.println("pre start-->uuid=" + getSelf().path().uid());
    }

    @Override
    public void preRestart(Throwable reason, Option<Object> message) throws Exception {
        System.out.println("pre restart-->reason=" + reason + "-->message=" + message);
    }

    @Override
    public void postRestart(Throwable reason) throws Exception {
        System.out.println("post restart-->reason=" + reason);
    }

    @Override
    public void postStop() throws Exception {
        System.out.println("post stop");
    }

    @Override
    public void onReceive(Object msg) throws Exception {
        System.out.println("receive msg=" + msg);
        if (msg instanceof String) {
            if ("error".equals(msg)) {
                throw new Exception("actor exception");
            }
        }
    }
}
